<?php

namespace app\model;

use think\model\concern\SoftDelete;

/**
 * 试题答案
 *
 * @author suiyuan
 */
class DynamicComment extends \think\Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_at';
    protected $defaultSoftDelete = 0;
    protected $table = 'dynamic_comment';

    protected $field = ['dynamic_id', 'content', 'create_at', 'delete_at'];
    /*
     * 新增前
     */
    public static function onBeforeInsert($model)
    {
        $model->user_id = request()->uid;
    }   
    /**
     * 用户
     *
     * @return void
     */
    public function dynamic() {
        return $this->belongsTo('Dynamic','dynamic_id')->bind(['status', 'title']);
    }
    /**
     * 用户
     *
     * @return void
     */
    public function user() {
        return $this->hasOne('User','user_id')->bind(['nickname']);
    }
}
